package cn.study.luckyapp.assembler;

import cn.study.luckyapp.award.command.AwardAddCmdExe;
import cn.study.luckyclient.dto.AwardAddCmd;
import cn.study.luckyclient.dto.AwardUpdateCmd;
import cn.study.luckyclient.dto.data.AwardVo;
import cn.study.luckydomain.award.AwardEntity;
import cn.study.luckydomain.award.AwardNumber;

import java.time.LocalDateTime;

public class AwardAssembler {
    public static AwardVo toAwardVo(AwardEntity awardEntity){
        AwardVo awardVo = new AwardVo();
        awardVo.setId(awardEntity.getId());
        awardVo.setActivityId(awardEntity.getActivityId());
        awardVo.setPrizeId(awardEntity.getPrizeId());
        awardVo.setNumber(awardEntity.getNumber().getNumber());
        awardVo.setAwardName(awardEntity.getAwardName());
        awardVo.setProbability(awardEntity.getProbability());
        awardVo.setCreateTime(awardEntity.getCreateTime());
        awardVo.setCreator(awardEntity.getCreator());
        awardVo.setUpdateTime(awardEntity.getUpdateTime());
        awardVo.setUpdater(awardEntity.getUpdater());
        return awardVo;
    }
    public static AwardEntity toEntity(AwardAddCmd awardAddCmd){
        AwardEntity awardEntity = new AwardEntity();
        awardEntity.setActivityId(awardAddCmd.getActivityId());
        awardEntity.setPrizeId(awardAddCmd.getPrizeId());
        awardEntity.setNumber(new AwardNumber(awardAddCmd.getNumber()));
        awardEntity.setAwardName(awardAddCmd.getAwardName());
        awardEntity.setProbability(awardAddCmd.getProbability());
        awardEntity.setCreateTime(LocalDateTime.now());
        awardEntity.setCreator("小三");
        awardEntity.setUpdateTime(LocalDateTime.now());
        awardEntity.setUpdater("小三");
        return awardEntity;
    }
    public static AwardEntity toEntity(AwardUpdateCmd awardUpdateCmd){
        AwardEntity awardEntity = new AwardEntity();
        awardEntity.setId(awardUpdateCmd.getId());
        awardEntity.setActivityId(awardUpdateCmd.getActivityId());
        awardEntity.setPrizeId(awardUpdateCmd.getPrizeId());
        awardEntity.setNumber(new AwardNumber(awardUpdateCmd.getNumber()));
        awardEntity.setAwardName(awardUpdateCmd.getAwardName());
        awardEntity.setProbability(awardUpdateCmd.getProbability());
        awardEntity.setCreateTime(LocalDateTime.now());
        awardEntity.setCreator("小三");
        awardEntity.setUpdateTime(LocalDateTime.now());
        awardEntity.setUpdater("小三");
        return awardEntity;
    }

}
